package com.yoooya.base.third.service;

import com.yoooya.base.dao.third.AccessTokenMapper;
import com.yoooya.base.model.po.third.AccessTokenPo;
import com.yoooya.base.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional
public class CommonService {
	@Autowired
	private AccessTokenMapper tokenMapper;
	@Value("${server.domain}")
	private String serverDomain;

	private static final Logger logger = LoggerFactory.getLogger(CommonService.class);

	public AccessTokenPo getAccessToken(Long tokenId) throws Exception {
		AccessTokenPo token = this.tokenMapper.queryById(tokenId);
		return token;
	}

	public void updateToken(Long tokenId, String tokenCode, Integer expiresIn) {
		this.tokenMapper.updateToken(tokenId, tokenCode, expiresIn, DateUtils.getSecondTime(), new Date());
	}
}